package kizzo.game 
{
	import flash.geom.Point;
	import kizzo.geometry.PointOperations2D;
	import kizzo.geometry.TileCoord3D;

	public class RotationModifier extends LinkModifier
	{
		public var angle:int = 0;
		
		public function RotationModifier() 
		{
			
		}
		
		override public function apply(v:TileCoord3D):TileCoord3D
		{			
			//var p:Point = PointOperations2D.rotate(new Point(v.x, v.z), angle);
			
			var p:TileCoord3D;
			
			switch (angle)
			{
				case 0:
						{
							p = new TileCoord3D( v.x, v.y, v.z);
							break;
						}
				case 1:
						{
							p = new TileCoord3D( -v.z, v.y, v.x);
							break;
						}
				case 2:
						{
							p = new TileCoord3D( -v.x, v.y, -v.z);
							break;
						}
				case 3:
						{							
							p = new TileCoord3D( v.z, v.y, -v.x);
							break;
						}						
					
			}			
			return p;
		}
		
		
		public function increment():void
		{
			this.angle++;
			this.angle = this.angle % 4;
		}
		
		public function decrement():void
		{
			this.angle+=3;
			this.angle = this.angle % 4;			
		}
	}

}